package com.touzhijia.scheduler.controller;

import com.touzhijia.common.controller.BaseController;
import com.touzhijia.common.persistence.Page;
import com.touzhijia.scheduler.service.JobLogService;
import com.touzhijia.scheduler.vo.request.JobLogQueryVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.validation.BindingResult;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.validation.Valid;

/**
 * 作者：lizw <br/>
 * 创建时间：2017/6/2 10:53 <br/>
 */
@Controller
@RequestMapping(value = "/quartz/jobLog")
public class JobLogController extends BaseController {

    @Autowired
    private JobLogService qrtzJobLogService;

//    @RequestMapping("/JobDetailLog" + VIEW_PAGE_SUFFIX)
//    public ModelAndView getJobDetailLogJsp(HttpServletRequest request, HttpServletResponse response) {
//        return new ModelAndView(QuartzJspUrlPath.JobDetailLog);
//    }

    @RequestMapping("/findJobLogByPage")
    @ResponseBody
    public Object findJobLogByPage(HttpServletRequest request,
                                   HttpServletResponse response,
                                   @Valid JobLogQueryVo jobLogQueryVo,
                                   BindingResult bindingResult) {
        return qrtzJobLogService.findByPage(new Page<>(request, response),
                jobLogQueryVo.getSchedulerName(),
                jobLogQueryVo.getInstanceName(),
                jobLogQueryVo.getJobGroup(),
                jobLogQueryVo.getJobName(),
                jobLogQueryVo.getJobClassName(),
                jobLogQueryVo.getStartTimeByStart(),
                jobLogQueryVo.getStartTimeByEnd(),
                jobLogQueryVo.getProcessTimeByMin(),
                jobLogQueryVo.getProcessTimeByMax());
    }
}
